package com.example.activities;

import com.example.dao.DatabaseUtility;
import com.example.demo.R;

import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ListView;

public class MainActivity extends ActionBarActivity {
	ListView lvAction;
	Intent actionIntent;
	int countActionReady = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main);

		DatabaseUtility db = new DatabaseUtility(MainActivity.this);
		db.open();
		db.close();
		
		lvAction = (ListView) findViewById(R.id.listActionSpinner);
		ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(
				MainActivity.this, android.R.layout.simple_dropdown_item_1line,
				getResources().getStringArray(R.array.list_action));
		lvAction.setAdapter(dataAdapter);
		lvAction.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> _adapterView, View _view,
					int _position, long _longValue) {
				// TODO Auto-generated method stub
				switch (_position) {
				case 0:
					actionIntent = new Intent(MainActivity.this,
							SendSMSPage.class);
					startActivity(actionIntent);
					break;
				case 1:
					actionIntent = new Intent(MainActivity.this,
							NotificationPage.class);
					startActivity(actionIntent);
					break;
				case 2:
					actionIntent = new Intent(MainActivity.this,
							HttpPostREQPage.class);
					startActivity(actionIntent);
					break;
				case 3:
					actionIntent = new Intent(MainActivity.this,
							AsyncTaskPostDataPage.class);
					startActivity(actionIntent);
					break;
				case 4:
					actionIntent = new Intent(MainActivity.this,
							AsyncTaskDataByGraph.class);
					startActivity(actionIntent);
				default:
					break;
				}
			}
		});

	}

}
